/* 
 * tonydon v1.0
 */
document.domain='uuola.com';
var imgRnd = ut.rndint(0, 6);
var IMG_DOMAIN = 'http://img'+imgRnd+'.uuola.com';
var KindUpload={
    fileMgrUrl:IMG_DOMAIN+'/kindupload/filemgr.jsp',
    UploadUrl:IMG_DOMAIN+'/kindupload/uper.jsp'
};
var Uploadify={
    resizeUrl:IMG_DOMAIN + '/uploadify/popIndex.jsp'
};

var MGR ={
    out:function(x){
        if(x.indexOf('timeout')>0 || x.indexOf('deny')>0){
            alert('登陆超时,没有权限.');
            ut.gopage('../');
        }
    },
    logout:function(){
        ut.gopage(def.ctx+'/wsm/');
    },
    loadRoleSel:function(func){
        $.get(def.ctx+'/wsm/app/admin/list_role_base.shtm?'+ut.r(),function(x){
            var a=[];
            var opt = '<option value="@id">@t</option>';
            a.push('<option value=""></option>');
            for(var k in x){
                a.push(opt.replace(/@id/,x[k].roleid).replace(/@t/,x[k].rolename));
            }
            $('#roleid').html(a.join(''));
            if(!va.isnull(func))
                ut.delay(func);
        }); 
    }
};

$(function(){
    $(".tbchg").delegate("tr","hover",function(){
        $(this).toggleClass("s_msover");
    });
});

var TxBox={
    alert:function(msg,time){
        $.dialog({
            id:'alert_box',
            fixed:true,
            title:'操作提示：',
            lock:true,
            content:msg
        });
        if(!va.isnull(time)){
            $.dialog.get('alert_box').time(time);
        }
    },
    wait:function(s){
        var t = va.isnull(s)?'正在处理数据...请稍后':s;
        $.dialog({
            id:'wait_box',
            title:false,
            fixed:true,
            width:'250px',
            content:'<span style="color:#1965E1">'+t+'</span>'
        });
    },
    changeWaitContent:function(t,time,func){
        $.dialog.get('wait_box').content('<span style="color:#1965E1">'+t+'</span>');
        if(!va.isnull(time) && !va.isnull(func)){
            ut.wait(func, time);
        }
    },
    hide:function(){
        $.dialog.get('wait_box').time(800);
    },
    // 通过GET URL获取内容并显示
    load:function(t,url){
        $.get(url,function(x){
            $.dialog({
                id:'load_box',
                title:t,
                content:x,
                lock:true,
                fixed:true
            });
        });
    },
    closeLoad:function(){
        $.dialog.get('load_box').time(300);
    },
    upload:function(eid,fg,fc){
        var func = fc||'';
        var flag = fg||'';
        if(va.isnull(eid)){
            alert('上传参数设置错误');
            return;
        }
       // var url = [def.ctx,'/upfs/post.jsp?t=',ut.r(),'&eid=',eid,'&flag=',flag,'&call=',func].join('');
        var crossUrl = [Uploadify.resizeUrl,'?ttt=',ut.r(),'&eid=',eid,'&flag=',flag,'&call=',func,'&close=TxBox.closeUpload'].join('');
        var x='<iframe src="'+crossUrl+'" allowtransparency="true" frameborder="0" width="425" height="148" scrolling="no"></iframe>';
        $.dialog({
            id:'upload_box',
            title:'上传图片',
            content:x,
            lock:true,
            fixed:true
        });
    },
    closeUpload:function(){
        $.dialog.get('upload_box').time(300);  
    },
    winpop:function(w,h,t,url){
        var x=['<iframe src="',url,'" allowtransparency="true" frameborder="0" width="',w+9,'" height="',h+9,'" scrolling="auto"></iframe>'].join('');  
        $.dialog({
            id:'winpop_box',
            title:t,
            content:x,
            lock:true,
            fixed:true
        });
    },
    closeWinpop:function(){
        $.dialog.get('winpop_box').time(300); 
    }
};

var IMG={
    // 重设img图片展示
    reset:function(imgid,pic){
        if(va.isnull(pic)){
            $('#img_'+imgid).hide();
        }else{
            $('#img_'+imgid).attr('src',pic+'?t='+ut.r()).show();
        }
    }
};


var CateUtil={
    getCidByCtp:function(ctp,level){
        if(va.isnull(ctp))
            return 0;
        var cida = (ctp.substring(0,ctp.length-1)).split('-');
        var le = 0;
        if(va.isnull(level)){
            le = cida.length-1 ;
        }else{
            le = Number(level);
        }
        return cida[le];
    }
};

// 评论状态
function getCmtState(k){
    var t={'0':'<span style="color:red;">×</span>','1':'<span style="color:blue;">√</span>'};
    return t[k];
};

// 发布状态
function getPubState(k){
    var t={'0':'<span style="color:red;">×</span>','1':'<span style="color:blue;">√</span>'};
    return t[k];
};
